<!DOCTYPE html>
<html>
    <head>
        <script src="js/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <button v-on:click="add">增加学生</button>
            <button @click="del">删除学生</button>
            <table border="1" width="50%" style="border-collapse: collapse;">
                <tr>
                    <th>班级</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>年龄</th>
                </tr>
                <tr align="center" v-for="stu in students">
                    <td> {{stu.grade}} </td>
                    <td> {{stu.name}} </td>
                    <td> {{stu.gender}} </td>
                    <td> {{stu.age}} </td>
                </tr>
            </table>
        </div>
        <script>
            var vm = new Vue({
                el:'#app',
                data : {
                    students:[{grade:1,name:'李田君',gender:'男',age:19},
                    {grade:1,name:'李田君',gender:'男',age:19}]
                },
                methods : {
                    add(){
                        var stu = {grade:'1',name : '周蔡',gender:'男',age: 19};
                        this.students.push(stu);
                    },
                    del(){
                        this.students.pop();
                    }
                }
            });
        </script>
    </body>
</html>